﻿package com.devilcat.dt
{	
	import com.devilcat.dt.Playerdt
	import flash.display.MovieClip;
	import com.devilcat.ui.*;
	import com.devilcat.ws.*;
	import com.devilcat.dt.*;

	public class Gamedt {
		public static var Player:Playerdt = new Playerdt();
		public static var PokemonList:Array;
		public static var ItemList:Array;
		public static var BallList:Array;
		public static var OtherPlayerList:Array = new Array();;
		public static var movesXML:XML;
		public static var itemsXML:XML;
		public static var pokemonsXML:XML;
		public static var mapsXML:XML;
		public static var isBattle:Boolean = false;
		public static var isLogin:Boolean = false;
		public static var loging:Boolean = false;
		public static var pvpAI:Boolean = false;
		public static var pvp:Boolean = false;
		//public static var mainClip:MovieClip;
		public static var MainUI:Mainui;
		public static var BattleUI:MovieClip;
		public static var PokemonListUI:PokemonListui;
		public static var ItemListUI:ItemListui;
		public static var updatePokemon:UpdatePokemonws;// = new UpdatePokemonws();
		public static var updatePokemonPVP:PVPUpdatePokemonws = new PVPUpdatePokemonws;// = new UpdatePokemonws();
		public static var updateItem:UpdateItemws;// = new UpdateItemws();
		public static var updatePlayer:UpdatePlayerInforws;// = new UpdatePlayerInforws();
		public static var updateEvent:UpdateUserEventws;
		public static var pvpws:PVPws = new PVPws();
		static const BUG = 0;		static const DARK = 1;		static const DRAGON = 2;
		static const ELECTRIC = 3;	static const FIGHT = 4;		static const FIRE = 5;
		static const FLYING = 6;	static const GHOST = 7;		static const GRASS = 8;
		static const GROUND = 9;	static const ICE = 10;		static const NORMAL = 11;
		public static const POISON = 12;	static const PSYCHIC = 13;	static const ROCK = 14;
		public static const STEEL = 15;	static const WATER = 16;	static const NONE = 17;		
		public static var typeChart:Array = new Array(	[1,2,1,1,0.5,0.5,0.5,0.5,2,1,1,1,0.5,2,1,0.5,1,1],
									[1,0.5,1,1,0.5,1,1,2,1,1,1,1,1,2,1,0.5,1,1],
									[1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,0.5,1,1],
									[1,1,0.5,0.5,1,1,2,1,0.5,0,1,1,1,1,1,1,2,1],
									[0.5,2,1,1,1,1,0.5,0,1,1,2,2,0.5,0.5,2,2,1,1],
									[2,1,0.5,1,1,0.5,1,1,2,1,2,1,1,1,0.5,2,0.5,1],
									[2,1,1,0.5,2,1,1,1,2,1,1,1,1,1,0.5,0.5,1,1],
									[1,0.5,1,1,1,1,1,2,1,1,1,0,1,2,1,0.5,1,1],
									[0.5,1,0.5,1,1,0.5,0.5,1,0.5,2,1,1,0.5,1,2,0.5,2,1],
									[0.5,1,1,2,1,2,0,1,0.5,1,1,1,2,1,2,2,1,1],
									[1,1,2,1,1,0.5,2,1,2,2,0.5,1,1,1,1,0.5,0.5,1],
									[1,1,1,1,1,1,1,0,1,1,1,1,1,1,0.5,0.5,1,1],
									[1,1,1,1,1,1,1,0.5,2,0.5,1,1,0.5,1,0.5,0,1,1],
									[1,0,1,1,2,1,1,1,1,1,1,1,2,0.5,1,0.5,1,1],
									[2,1,1,1,0.5,2,2,1,1,0.5,2,1,1,1,1,0.5,1,1],
									[1,1,1,0.5,1,0.5,1,1,1,1,2,1,1,1,2,0.5,0.5,1],
									[1,1,0.5,1,1,2,1,1,0.5,2,1,1,1,1,2,1,0.5,1],
									[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]);
									
		public static function newWildPokemon(XMLData):Pokemondt{
			var Pokemon:Pokemondt = new Pokemondt();
			Pokemon.setWildData(XMLData);
			return Pokemon;
		}		
		public static function delOtherPlayer(uid:Number){
			for(var i:int=0;i<OtherPlayerList.length;i++){
				if(OtherPlayerList[i].uid==uid){
					OtherPlayerList.splice(i,1);
				}
			}
		}
		public static function newWildPokemonList(XMLData):Array{
			var ArrayObject:Array=new Array();
			for(var i:int=0;i<XMLData.pkm.length();i++){
				ArrayObject.push(newWildPokemon(XMLData.pkm[i]));
			}
			return ArrayObject;
		}
		public static function StringID(_id:uint):String{
			if(_id<10) return "00"+_id;
			if(_id<100) return "0"+_id;
			return	""+_id;
		}
	}

}